#ifndef PM_COST_H_INCLUDED
#define PM_COST_H_INCLUDED

#include "pm/dbobject.h"
#include "pm/criteria.h"

namespace pm
{

/**
 * \class Cost
 */
class Cost : public db::Table
{
public:
	db::real   unit_cost;
	db::real   quantity;
	db::text   name;
	db::date   date;
	db::ID     id_task;
	
	static const wxString TABLE_NAME;
	
public:
	Cost();
	Cost(wxSQLite3ResultSet& res);

	double cost() const { return unit_cost() * quantity(); }

	// DB
	virtual bool load(wxSQLite3ResultSet& res);
	virtual db::update_value_t prepare_insert(wxSQLite3Database& db);
	virtual db::update_value_t prepare_update(wxSQLite3Database& db);
};

typedef std::list<Cost> ListCost;

/**
 * \class CostInfo
 */
class CostInfo : public Cost
{
public:
	static const wxString TABLE_NAME;

	db::ID   id_project;
	db::text task_name;

public:	
	CostInfo();
	CostInfo(wxSQLite3ResultSet& res);
};

/**
 * \class GetCostsByProject
 */
struct GetCostsByProject : public ICriteriaForEach<CostInfo>
{
	db::ID  id_project;
	
	GetCostsByProject(const db::ID& id_project);
	
	virtual wxSQLite3Statement prepare(wxSQLite3Database& db);
};

} // namespace pm

#endif // PM_COST_H_INCLUDED
